﻿// controller for the search by image results
angular.module('app.search').controller('SearchResultsByImageController', ['$scope', '$state', 'searchService',
	function ($scope, $state, searchService) {
		'use strict';

		var instance = this;
		// get criteria from the state parameters
		$scope.criteria = {
			imageId: $state.params.imageId
		};

		// perform search function
		this.performSearch = function () {
			// search for the image
			searchService.byImage($state.params.tolerance, $state.params.imageId).then($scope.handleGetImagesResponse);
		};

		// method to retry the search
		$scope.retry.setRetryMethod(function () {
			instance.performSearch();
		});
		// search for the results
		instance.performSearch();
	}]);